<?php

//if (!defined('BASEPATH'))
//    exit('No direct script access allowed');

class Users extends CI_Model {

    function __construct() {
        parent::__construct();
    }

    public function login($username, $password) {
        $this->db->select('id,username');
        $this->db->where('username', $username);
        $this->db->where('password', $password);
        $this->db->limit(1);
        $query = $this->db->get('users');
        if ($query->num_rows() === 1) {
            return $query->result_array();
        } else {
            return FALSE;
        }
    }

    public function logout() {
        $this->session->unset_userdata('logged_in');
        session_destroy();
        redirect(base_url());
    }

}
